import axios from "axios";
const a = axios.create({
    baseURL: '/qkj',
})
//封装带token的ajax请求
a.interceptors.request.use(function (config) {
    // Do something before request is sent
    let userInfo = localStorage.getItem('userInfo')
    try {
        userInfo = JSON.parse(userInfo) || {}
    } catch (err) {
        userInfo = {}
    }
    if (userInfo.token) {
        config.headers.token = userInfo.token

    }
    return config;
}, function (error) {
    // Do something with request error
    return Promise.reject(error);
});

export default a;